package com.lebang.medicalInquiry.model.chat;


import lombok.AllArgsConstructor;
import lombok.Data;
import org.springframework.web.servlet.mvc.method.annotation.SseEmitter;

import java.io.IOException;

@Data
@AllArgsConstructor
public class SseStreamListener extends AbstractEventSourceListener {

    private SseEmitter sseEmitter;


    @Override
    public void onMsg(String data) {
        try {

            sseEmitter.send(data);
        } catch (IOException e) {
//            throw new RuntimeException(e);

        }
    }
    @Override
    public void onError(Throwable throwable) {
        sseEmitter.complete();
    }
}
